package moreApi.src.regex;

import java.util.Scanner;

public class RegexTest {
    public static void main(String[] args) {
        //校验手机号,邮箱和电话号码
        if(checkPhone()){
            System.out.println("这真是个手机号");
        }
        if(checkMail()){
            System.out.println("邮箱合法");
        }
    }
    public static boolean checkPhone(){
        Scanner sc = new Scanner(System.in);
        System.out.print("请输入您的手机号:");
        String s = sc.next();
        //手机号格式,首位1,次位3开始
        return s.matches("1[3-9]\\d{9}");
    }
    public static boolean checkMail(){
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入您的邮箱:");
        String s = sc.next();
        //手机号格式,首位1,次位3开始
        return s.matches("[\\w&&[^_]]+@[\\w&&[^_]]+(\\.[\\w&&[^_]]+){1,2}");
    }
}
